﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

using ThuVienCT;

namespace QLCTNA
{
    public partial class Frm_nguyenlieu : Form
    {
        private ConnectionData cnn = null;
        public Frm_nguyenlieu()
        {
            InitializeComponent();
            FileText ft = new FileText("Config\\Config.ini");

            this.MaximizeBox = false;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            cnn = Connection.Connect();
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void BtnSave_Click(object sender, EventArgs e)
        {


            string insert = null;
            int check = 0;
            if (cnn.Check())
            {
                insert = " insert into vw_NguyenLieu([Mã Nguyên Liệu],[Mã Công Thức],[Nguyên Liệu])" + "values({0},{1},{2});";
                check = cnn.Execute(insert,txtma.Text,txtmacongthuc.Text,rtbnguyenlieu.Text);
                if (check > 0)
                {
                    MessageBox.Show("Bạn Đã Lưu Thành Công", "thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Không lưu thành công!!!", "thong bao", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
               
            }

        }

       

        private void btnClose_Click(object sender, EventArgs e)
        {
           Frm_nguyenlieu frm =new Frm_nguyenlieu();
           frm.Hide();
        }

        private void Frm_nguyenlieu_Load(object sender, EventArgs e)
        {

        }

        private void rtbnguyenlieu_TextChanged(object sender, EventArgs e)
        {

        }


        
    }
}
